import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:material_collection_app/utils/utils.dart';

class DialogTask extends StatelessWidget {
  final int id;
  final bool showButton;

  DialogTask({Key key, this.id, this.showButton = false}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: false);

    return Dialog(
        child: Container(
            width: 530.w,
            height: 630.w,
            child: Stack(
              children: <Widget>[
                Column(
                  children: <Widget>[
                    Container(
                      margin: EdgeInsets.only(top: 30.w),
                      alignment: Alignment.topCenter,
                      child: Image.asset(
                        'assets/task.png',
                        width: 319.w,
                      ),
                    ),
                    Container(
                      alignment: Alignment.center,
                      margin: EdgeInsets.only(top: 50.w),
                      child: Column(
                        children: <Widget>[
                          Text('已接受任务',
                              style: TextStyle(
                                  color: Utils.hexToColor('#333333'),
                                  fontSize: 36.w,
                                  fontWeight: FontWeight.bold)),
                          Container(
                            margin: EdgeInsets.only(top: 23.w),
                            child: Text('请尽快去完成任务吧~',
                                style: TextStyle(
                                    color: Utils.hexToColor('#A6A3A6'),
                                    fontSize: 12,
                                    height: 1)),
                          )
                        ],
                      ),
                    ),
                    Offstage(
                      offstage: showButton ? false : true,
                      child: Container(
                        alignment: Alignment.center,
                        margin: EdgeInsets.only(top: 84.w),
                        child: SizedBox(
                          width: 290.w,
                          height: 76.w,
                          child: ElevatedButton(
                            onPressed: () {
                              Navigator.of(context).pop();
                              Navigator.pushNamed(context, '/enter_check',
                                  arguments: {'id': id});
                            },
                            child: Text(
                              '清点任务',
                              style: TextStyle(color: Colors.white),
                            ),
                            style: ElevatedButton.styleFrom(
                              backgroundColor: Color(0xFF297CFF),
                              shape: RoundedRectangleBorder(
                                  borderRadius:
                                      BorderRadius.all(Radius.circular(60.w))),
                            ),
                          ),
                        ),
                      ),
                    )
                  ],
                ),
                Positioned(
                    right: 0,
                    child: GestureDetector(
                      onTap: () {
                        Navigator.of(context).pop();
                      },
                      child: Container(
                        padding: EdgeInsets.all(24.w),
                        alignment: Alignment.topRight,
                        child: Image.asset(
                          'assets/dialog_close.png',
                          width: 36.w,
                        ),
                      ),
                    )),
              ],
            )));
  }
}
